//
//  YZLNewsLinkViewController.m
//  Car
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 岳明. All rights reserved.
//

#import "YZLNewsLinkViewController.h"

@interface YZLNewsLinkViewController () <UIWebViewDelegate>

@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) UIActivityIndicatorView *activity;

@end

@implementation YZLNewsLinkViewController

- (void)viewDidAppear:(BOOL)animated {
    self.navigationController.navigationBarHidden = NO;
   
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"资讯";
    
    //返回
    [self skipReturnWithTarget:self];
    
    //bar颜色
    [self navigationbarColor];
    
    self.webView = [[UIWebView alloc] init];
    self.webView.backgroundColor = [UIColor whiteColor];
    self.webView.frame = self.view.frame;
    self.webView.delegate = self;
    // 定义一个字符串用来判断是夜间还是白天
    NSString *nightStr = @"white";
    NSString *str = [NSString string];
    // 判断新闻类型，是新闻还是广告
    if ([self.typeString integerValue] == 2) {
        str = [NSString stringWithFormat:@"%@&themeType=%@&network=wifi&deviceType=iOS&fontSize=normal", self.urlString, nightStr];
    } else if ([self.typeString integerValue] == 1) {
        str = self.urlString;
        [self.webView sizeToFit];
    }
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:str]];
    [self.view addSubview:self.webView];
    [self.webView loadRequest:request];
    
    self.activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    self.activity.center = self.view.center;
    self.activity.frame = self.view.frame;
    self.activity.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.activity];
    [self.activity startAnimating];
//
}

#pragma mark - 隐藏tabBar
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [self.activity stopAnimating];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
